package xyz.xtt.exchange.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import cn.hutool.json.JSONUtil;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.extern.slf4j.Slf4j;
import xyz.xtt.common.objects.DozerUtil;
import xyz.xtt.common.response.ApiResult;
import xyz.xtt.exchange.entity.TblAssetAudit;
import xyz.xtt.exchange.request.CopyrightRequest;
import xyz.xtt.exchange.response.AssetAuditResponse;
import xyz.xtt.exchange.service.ITblAssetAuditService;
import xyz.xtt.exchange.service.ITblAssetCopyrightService;

@Schema(name = "exchange对外服务接口", description = "exchange对外服务接口")
@Slf4j
@RestController
@RequestMapping("/api/nft/exchange")
public class InnerExchangeController {
	@Autowired
	private ITblAssetAuditService iTblAssetAuditService;
	@Autowired
	private ITblAssetCopyrightService iTblAssetCopyrightService;

	@GetMapping("/assetAuditInfo")
	public ApiResult<AssetAuditResponse> assetAuditInfo(Long assetAuditId) {
		log.info("/api/nft/exchange/assetAuditInfo assetAuditId:{}", assetAuditId);
		TblAssetAudit assetAuditInfo = iTblAssetAuditService.assetAuditInfo(assetAuditId);
		AssetAuditResponse transfor = DozerUtil.transfor(assetAuditInfo, AssetAuditResponse.class);
		return ApiResult.ok(transfor);
	}

	@PostMapping("/assetAuditPayMint")
	public ApiResult<Boolean> assetAuditPayMint(@RequestParam("assetAuditId") Long assetAuditId, @RequestParam("assetId") Long assetId) {
		log.info("/api/nft/exchange/assetAuditPayMint assetAuditId:{},assetId:{}", assetAuditId, assetId);
		Boolean result = iTblAssetAuditService.assetAuditPayMint(assetAuditId, assetId);
		return ApiResult.ok(result);
	}

	@PostMapping("/saveCopyright")
	public ApiResult<Boolean> saveCopyrightEx(@RequestBody CopyrightRequest copyrightRequest) {
		log.info("/api/nft/exchange/saveCopyright request:{}", JSONUtil.toJsonStr(copyrightRequest));
		Boolean result = iTblAssetCopyrightService.saveCopyright(copyrightRequest);
		return ApiResult.ok(result);
	}
}
